package org.example.memberlist_back.controller;

import org.example.memberlist_back.common.Res;
import org.example.memberlist_back.entity.Member;
import org.example.memberlist_back.server.MemberServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController
public class MemberController  {
    @Autowired
    private MemberServer memberServer;
    @GetMapping("/getMemberList")
    public Res<List<Member>> getMemberList(){
        return memberServer.getMemberList();
    }
    @PostMapping("/addMember")
    public Res<String> addMember(@RequestBody Member member){

        return memberServer.addUser(member);
    }
    @DeleteMapping("/deleteMember")
    public Res<String> deleteMember(@RequestParam String id){

        return memberServer.deleteUser(id);
    }
    @PutMapping("/updateMember")
    public Res<String> updateMember(@RequestBody Member member){
        return memberServer.updateUser(member);
    }
}
